package com.maila.xiaoaoschool.api;

import android.content.Context;

import com.maila.xiaoaoschool.net.NetWork;
import com.maila.xiaoaoschool.net.VolleyInterface;
import com.maila.xiaoaoschool.util.Constants;

import java.util.HashMap;

/**
 * 店铺接口api
 * Created by mark on 2017/12/8.
 */

public class ShopApi extends NetWork {
    private static final String URL_SHOP = Constants.URL_ROOT_XIAOAO + "/index.php?ctrl=mapishop";

    public ShopApi(Context ctx, VolleyInterface listener) {
        super(ctx, listener);
    }


    /**
     * 店铺信息
     * @param shopid
     */
    public void getShopInfo(String shopid) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("shopid", shopid);
        requestPost(URL_SHOP, "shop_particulars", query);
    }

    /**
     * 店铺分类 列表
     * @param shopid
     */
    public void getShopClasses(String shopid) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("shopid", shopid);
        requestPost(URL_SHOP, "shop_classify", query);
    }

    /**
     * 店铺评价
     * @param shopid
     * @param page
     * @param size
     */
    public void getShopCpmments(String shopid, int page,int size) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("shopid", shopid);
        query.put("page", page);
        query.put("size", size);
        requestPost(URL_SHOP, "comment_all", query);
    }

    /**
     * 商品评价
     * @param goodsid
     * @param page
     * @param size
     */
    public void getGoodsCpmments(int goodsid, int page,int size) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("goodsid", goodsid);
        query.put("page", page);
        query.put("size", size);
        requestPost(URL_SHOP, "comment_alone", query);
    }

    /**
     * 商品信息
     * @param goodsid
     */
    public void getGoodInfo(String goodsid) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("goodsid", goodsid);
        requestPost(URL_SHOP, "goods_particulars", query);
    }

    /**
     * 添加到购物车
     * @param goodsid
     * @param goodsname
     * @param goodscost
     * @param goodscount
     * @param shopid
     */
    public void add_to_cart(String goodsid,String goodsname,String goodscost,String goodscount,String shopid){
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("goodsid", goodsid);
        query.put("goodsname", goodsname);
        query.put("goodscost", goodscost);
        query.put("goodscount", goodscount);
        query.put("shopid", shopid);
        requestPost(URL_SHOP, "add_shopping_cart", query);
    }

    /**
     * 获取购物车列表
     * @param shopid
     */
    public void getcartlist(String shopid) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("shopid", shopid);
        requestPost(URL_SHOP, "shopping_cart_list", query);
    }

    /**
     * 清空购物车列表
     * @param shopid
     */
    public void clearcartlist(String shopid) {
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("shopid", shopid);
        requestPost(URL_SHOP, "del_shopping_cart_list", query);
    }

    /**
     * 该商品是否收藏
     * @param goodid
     */
    public  void  checkcollection(int goodid){
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("goodid", goodid);
        requestPost(URL_SHOP, "collect", query);
    }


    //订单

    /**
     * 提交订单
     * @param shopid
     * @param quanid
     * @param addressid
     * @param content
     * @param shopps
     * @param lat
     * @param lng
     * @param ordertype
     * @param goodsinfo
     */
    public  void send_order(String shopid,String quanid,String addressid,String content,String shopps,String lat,String lng,String ordertype,String goodsinfo){
        HashMap<String ,Object> query=new HashMap<>();
        query.put("shopid",shopid);
        query.put("quanid",quanid);
        query.put("addressid",addressid);
        query.put("content",content);
        query.put("shopps",shopps);
        query.put("lat",lat);
        query.put("lng",lng);
        query.put("ordertype",ordertype);
        query.put("goods",goodsinfo);
        requestPost(URL_SHOP,"place_order",query);
}

    /**
     * 获取待评价的订单信息
     * @param orderid
     */
    public  void  get_no_commentorder_info(String orderid){
        HashMap<String, Object> query = new HashMap<String, Object>();
        query.put("orderid", orderid);
        requestPost(URL_SHOP, "no_comment", query);
    }

    /**
     * 订单评价
     * @param orderid
     * @param psypoint
     * @param point
     * @param content
     * @param img
     * @param goodsid_all
     * @param shopid
     */
    public  void send_comment(String orderid,String psypoint,String point,String content,String img,String goodsid_all,String shopid){
        HashMap<String ,Object> query=new HashMap<>();
        query.put("orderid",orderid);
        query.put("psypoint",psypoint);
        query.put("point",point);
        query.put("content",content);
        query.put("img",img);
        query.put("goodsid_all",goodsid_all);
        query.put("shopid",shopid);
        requestPost(URL_SHOP,"comment",query);
    }

    /**
     * 提现
     * @param cost
     * @param paypwd
     */
    public void    withdraw(String  cost,String  paypwd){
        HashMap<String ,Object> query=new HashMap<>();
        query.put("cost",cost);
        query.put("paypass",paypwd);
        requestPost(URL_SHOP,"withdrawals",query);
    }

}
